#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->listWidget->addItem("123");
    ui->listWidget->addItem("456");
    ui->listWidget->addItem("789");

}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QString text = ui->lineEdit->text();
    if(text.isEmpty())
        return;
    else
        ui->listWidget->addItem(text);
}

void Widget::on_pushButton_2_clicked()
{
    int row = ui->listWidget->currentRow();
    ui->listWidget->takeItem(row);
}
